<template>
	<web-view :src="modifiedUrl" @message="getMassage"></web-view>
	<!-- <web-view src="http://127.0.0.1:8848/ArcGis/index.html"></web-view> -->
</template>

<script>
	export default {
		props: {
			url: {
				type: String,
				default: ''
			},
			type: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				// modifiedUrl: this.url
				modifiedUrl: '',
			}
		},

		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			let path = '/pages/webView/webView?url=' + this.modifiedUrl
			if (this.modifiedUrl.includes('ArcGis')) {
				path = '/pages/center/index?index=2';
			}
			return {
				title: this.$category.appName, //分享的名称
				path: path,
				mpId: this.$category.appid //此处配置微信小程序的AppId
			}
		},
		onLoad(e) {
			console.log(e)
			this.modifiedUrl = this.url;
		},
		methods: {
			getMassage(event) {
				console.log('11111111111111111111')
				console.log(event)
				const data = JSON.parse(event.detail.data[0]);
				if (data.type == "导航") {
					this.golocal(data.lat, data.lng, data.title)
				}
			},
			//实际点位导航
			golocal(lat, lnt, title) {
				uni.openLocation({
					latitude: Number(lat), //目标纬度
					longitude: Number(lnt), //目标经度
					name: title, //名称
					scale: 28
				});
			},
		},
	}
</script>

<style>
</style>